# gflags.cmake
# 本文件包含着从外部导入 gflags 所需要的信息

INCLUDE(ExternalProject)

set(GFLAGS_ROOT ${PROJECT_SOURCE_DIR}/extern_module_download/gflags)
set(GFLAGS_GIT_URL      https://atomgit.com/dangaldb/gflags-Mirror.git)  # 指定git仓库地址
set(GFLAGS_CONFIGURE    cd ${GFLAGS_ROOT}/src/extern_gflags && rm -rf build && mkdir build)
set(GFLAGS_MAKE         cd ${GFLAGS_ROOT}/src/extern_gflags && cmake . -DCMAKE_INSTALL_PREFIX=${GFLAGS_ROOT}/output)
set(GFLAGS_INSTALL      cd ${GFLAGS_ROOT}/src/extern_gflags && make install) 

ExternalProject_Add(extern_gflags
        PREFIX            ${GFLAGS_ROOT}
        GIT_REPOSITORY    ${GFLAGS_GIT_URL}
        CONFIGURE_COMMAND ${GFLAGS_CONFIGURE}
        BUILD_COMMAND     ${GFLAGS_MAKE}
        INSTALL_COMMAND   ${GFLAGS_INSTALL}
        CMAKE_ARGS
        -DCMAKE_INSTALL_PREFIX=${GFLAGS_ROOT}/output
        -DBUILD_SHARED_LIBS=OFF
)

INCLUDE_DIRECTORIES(${GFLAGS_ROOT}/output/include)
LINK_DIRECTORIES(${GFLAGS_ROOT}/output/lib)